from datetime import date

from peewee import *

db = MySQLDatabase(
    "spider",
    host="127.0.0.1",
    port=3306,
    user='root',
    password="123456"
)


class Person(Model):
    name = CharField(max_length=50)
    birthday=DateField()

    class Meta:
        database = db
        table_name = "users"


if __name__=="__main__":
    db.create_tables([Person])

    # 生成数据
    # person = Person(name="Bob", birthday=date(1993,10,15))
    # person.save()
    # bob = Person.select().where(Person.name=="Bob").get()
    bob = Person.get(Person.name == 'Bob')
    print(bob.birthday)